package com.zkingsoft.services.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zkingsoft.dao.CodeReviewDao;
import com.zkingsoft.dao.ReviewDetailDao;
import com.zkingsoft.model.CodeReview;
import com.zkingsoft.model.ReviewDetail;
import com.zkingsoft.plugin.pojo.PaginationVO;
import com.zkingsoft.services.CodeReviewService;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2016-11-10 16:57
 */
@Service("codeReviewService")
public class  CodeReviewServiceImpl implements    CodeReviewService  {

	
	@Autowired
	private CodeReviewDao codeReviewDao;
	@Autowired
	private ReviewDetailDao reviewDetailDao;
	
	@Override
	@Transactional
	public int add(CodeReview codeReview){
		int result = codeReviewDao.insert(codeReview);
		Long reviewId = codeReview.getId();
		List<ReviewDetail> reviewDetailList = codeReview.getReviewDetailList();
		for(ReviewDetail reviewDetail : reviewDetailList){
			reviewDetail.setReviewId(reviewId);
		}
		reviewDetailDao.inserts(reviewDetailList);		
		return result;	
	}
   	
    @Override
	public int modify(CodeReview codeReview){
	
		return codeReviewDao.update(codeReview);
	
	}
	
	@Override
	public int remove(List<Long> list){
	
		return codeReviewDao.deleteByIds(list);
	
	}

	@Override
	public int removeById(Long id){
	
		return codeReviewDao.deleteById(id);
	
	}
	
	@Override
	public int removeByModel(CodeReview codeReview){
	
		return codeReviewDao.deleteByModel(codeReview);
	
	}
	
	
	@Override
	public List<CodeReview> findInPage(CodeReview codeReview,  PaginationVO pageVo){
	
		return codeReviewDao.selectInPage(codeReview , pageVo);
	
	}
	
	@Override
	public List<CodeReview> findByModel(CodeReview codeReview){
	
		return codeReviewDao.selectByModel(codeReview);
	
	}
	
	@Override
	public int  findTotal(CodeReview codeReview){
	
		return codeReviewDao.selectTotalRecord(codeReview);
	
	}
	
	@Override
	public CodeReview  findById(Long id){
	
		return codeReviewDao.selectById(id);
	
	}

   	
	
	
}